<?php

/**
 * @Author: suyuan
 * @Email: 819067126@qq.com
 * @Date: 2020/09/16 13:59
 */


class myPDO
{
    private $dsn = "mysql:host=localhost;dbname=study";
    private $user = "root";
    private $password = "123456";
    public $conn = "";
    public function __construct()
    {
        return $this->conn = new PDO($this->dsn, $this->user, $this->password);
    }

    public function getDetail($Table)
    {
        $sql = sprintf("SELECT * FROM %s", $Table);
        $stmt = $this->conn->prepare($sql);
        $stmt->execute();
        $res =  $stmt->fetchAll(PDO::FETCH_ASSOC);
        return $res;
    }
}


$db = new myPDO;

$res = $db->getDetail('devices');
var_dump($res);
